<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	include('includes/db/sql.functions.php');
	//Validar por PHP: ver si esta en la BD el BB
	$newBb= $_POST['bbname'];
	$ourBbs=get_all_biobits();
	$isThere = false;
	
	foreach($ourBbs['query'] as $clave => $valor){
		$a=$ourBbs['query'][$clave]['bb_name'];
		 
		if($a == $newBb){
			$isThere=true;
			break;
		}

	}
	
	if(!$newBb || $newBb==""){	
		$_SESSION["errores"]="BioBit name can't be empty";
		header('Location: searchbiobit.php'); 
	
	}else{
		$_SESSION["errores"]="";
		if($isThere){

			header("Location: addWire.php?bb=$newBb");

				
		}else{
			header("Location: newBiobit.php?bb=$newBb");
		}
		 
	}
}
?>
